package lynnn;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Lyn
 * Date: 2025-01-20
 * Time: 15:43
 */
public class Computer implements IUSB{

    @Override
    public void openDevise() {
        System.out.println("打开电脑");
    }

    @Override
    public void closeDevise() {
        System.out.println("关闭电脑");
    }

    public void useDevice(IUSB usb){
        usb.openDevise();
        if(usb instanceof Mouse){
            Mouse mouse = (Mouse) usb;
            mouse.click();
        }else if(usb instanceof KeyBorad){
            KeyBorad keyBorad = (KeyBorad)usb;
            keyBorad.inPut();
        }
        usb.closeDevise();
    }


    public static void main(String[] args) {
        Computer computer = new Computer();
        computer.openDevise();

        computer.useDevice(new Mouse());
        computer.useDevice(new KeyBorad());

        computer.closeDevise();
    }
}
